home *** CD-ROM | disk | FTP | other *** search
- #include <assert.h>
- #include <stdio.h>
- #include "zlib.h"
- #include "zutil.h"
-
- int main(int argc, char *argv[])
- {
- char *compr;
- char uncompr[99999];
- FILE* fp;
- int err;
- uLong uncomprLen, comprLen;
-
- /* We want status messages */
- z_verbose = 1;
-
- fp = fopen("graphic.wmf.lzzed", "r");
- assert(fp);
-
- /* Figure out the size of the file in a boring way*/
- assert(fseek(fp, 0, SEEK_END) == 0);
- comprLen = ftell(fp);
- assert(fseek(fp, 0, SEEK_SET) == 0);
-
- /* Read in the file contents */
- assert(compr = malloc(comprLen));
- assert(fread(compr, comprLen, 1, fp));
- fclose(fp);
-
- uncomprLen = sizeof(uncompr); /* This was the trick :( */
- err = uncompress(uncompr, &uncomprLen, compr, comprLen);
-
- if (err != Z_OK) {
- fprintf(stderr, "error: %d\n", err);
- exit(1);
- }
-
- /* Write out uncompressed data */
- assert(fp = fopen("t.t", "w"));
- assert(fwrite(uncompr, uncomprLen, 1, fp));
- fclose(fp);
-
- return 0;
- }
-